﻿using System;
using System.ServiceProcess;
using System.Threading;
using Biz.Process;
using Hjt212Parser;
using log4net;

namespace Biz
{
    public partial class BizProcessor : ServiceBase
    {
        private ILog log = LogManager.GetLogger(typeof(BizProcessor));
        int milliSeconds = 100;
        public BizProcessor()
        {
            InitializeComponent();
        }
        //test
        public void Main()
        {
            OnStart(null);
        }
        protected override void OnStart(string[] args)
        {
            //启动各路线程
            new Thread(Process).Start();
            new Thread(new ProcessorMonthPlan().GenMonthPlan).Start();
            log.Info("各路线程启动完成...");
        }
        protected override void OnStop()
        {
            log.Info("The processor stopped!");
        }
        private void Process(object state)
        {
            while (true)
            {
                try
                {
                    new CommonProcessor().Process();
                }
                catch (Exception ex)
                {
                    log.Error( ex);
                }
                finally
                {
                    ThreadUtil.Sleep(milliSeconds);
                }
            }
            // ReSharper disable once FunctionNeverReturns
        }
       
      
    }
}
